
import ast
import asyncio
import json
import os
import re
import threading
from concurrent.futures._base import wait, ALL_COMPLETED
from random import randint
from string import Template
from typing import Any
import httpx
import jsonpath
import openpyxl
import requests
import uvicorn
from appium import webdriver
from fastapi import FastAPI
from sqlalchemy import select, delete
from sqlalchemy.ext.asyncio import AsyncSession

from emails.mail import Mail
from errors.platformError import ResponseException
from handle.apiDependent import ApiDependentHandle
from handle.uiDependent import UiDependentHandle
from initialization.redisInit import get_sync_redis
from model.entitys import Menu, get_sync_db, CaseGroup
from service.apiService import ApiService
from utils.typeUtil import TypeUtil
from utils import sum_value, random, reduce_value, ride_value, except_value, random
from variable import dependent_data, handle_thread_pool
import filetype
import argparse
import sys
from selenium import webdriver as web_driver
from multiprocessing import cpu_count













"""
模拟 sqlalchemy 一对多、多对多 统一操作
"""
async def o2m_add(session: AsyncSession, obj_in: Any, field: str, relation: str, backref: str = None):
    # obj_in:为映射数据库的model对象

    setattr(obj_in, relation, getattr(obj_in, field))
    delattr(obj_in, field)
    session.add(obj_in)

    await session.commit()

async def m2m_delete(session: AsyncSession, Pojo1, id: str, relation: str, field1, Pojo2, backref: str = None):
    # obj_in:为映射数据库的model对象

    obj = (await session.execute(select(Pojo1).where(Pojo1.id == id))).scalars().first()

    o_list = (await session.execute(select(Pojo2).where(getattr(Pojo2, field1) == id))).scalars().all()
    getattr(obj, relation).remove(o_list)

    await session.execute(delete(Pojo1).where(Pojo1.id == id))

    await session.commit()

async def m2m_update(session: AsyncSession, obj_in: Any, field1: str, relation: str, Pojo2, field2,
                     backref: str = None):
    # obj_in:为映射数据库的model对象

    o_list = (
        await session.execute(select(Pojo2).where(getattr(Pojo2, field2) == obj_in.id))).scalars().all()
    getattr(obj_in, relation).remove(o_list)

    setattr(obj_in, relation, getattr(obj_in, field1))
    delattr(obj_in, field1)
    session.add(obj_in)

    await session.commit()
























def get_parameter():
    parser = argparse.ArgumentParser(description='该脚本用于获取文件的类型')
    parser.add_argument('-f', dest='F:/test-platform-by-yang-liang/apiRecording/录制.xlsx', type=str, default='', help='输入待检测文件')
    args = parser.parse_args()
    inputFile = args.inputFile
    return inputFile

def main():
    inputFile = get_parameter()
    if inputFile == '':
        print('请输入待检测文件')
        sys.exit(1)
    ft1 = filetype.guess(inputFile)
    if ft1 is None:
        print('无法判断该文件类型')
    print('文件扩展名为：{}'.format(ft1.extension))
    print('文件类型为：{}'.format(ft1.mime))

m1 = {
        "a":"43",
        "b":9,
        "d":43.66,
        "e":True,
        "i":"iuwrr",
        "j": 54.86,
        "k": False,
        "n": 532,
        "o": 6.9,
        ("//","id"):0,
        "p":54
    }

def p(s: str):

    s += "kjhgsdg"

def exec_func(func: str) -> str:
    loc = locals()
    exec(f"result = {func}")
    return str(loc['result'])

# def exec_func(incoming_params: str) -> str:
#     funcs = re.findall('\\${(.*?)}', incoming_params)
#     print("funcs：", funcs)
#     if len(funcs) > 1:
#         for func in funcs:
#             func = func.replace('${%s}' % func, exec_func(func))
#     else:
#         exec(f"result = {funcs[0]}")
#
#     return str(locals()['result'])

def matching_variable(incoming_params :str) -> Any:
    incoming_params = Template(incoming_params).safe_substitute(m1)
    print("incoming_params：", incoming_params)

    funcs = re.findall('\\${(.*?)}', incoming_params)
    print("funcs：", funcs)
    for func in funcs:
        incoming_params = incoming_params.replace('${%s}' % func, exec_func(func))

    try:
        params = ast.literal_eval(incoming_params)
    except Exception as error:
        print("format error：", error)
        params = incoming_params

    return params


import time
# from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.schedulers.asyncio import AsyncIOScheduler

async def my_job():
    print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())))

app = FastAPI()

@app.post("/addSched")
async def root(d: dict):

    dependent_data["sched"].add_job(my_job, 'interval', seconds=5)

    # for k, v in d.items():
    #     dependent_data[k] = v

    return dependent_data

def a():
    dependent_data["a"] = 1
    print("dependent_data：", dependent_data)

def b():
    dependent_data["b"] = 2
    print("dependent_data：", dependent_data)

def c():
    dependent_data["c"] = 3
    print("dependent_data：", dependent_data)

def start_scheduled_task():
    pass

class D():
    pass

class A:

    def __init__(self):
        self.b = {
            "a":"rt5",
            "v":"hrt",
            "n":"hftg"
        }
        self.c = [
            1,2,5,"634",32.65
        ]
        self.d = None

class B(A, D):

    def fsd(self, a):
        return int(a)

class C(A):
    pass

def nnnn(z, x, c):
    print(z, x, c)

def ifff(a):
    if a > 5:
        return 7

def gdfgfd(m):
    m["vbvn"] = 6.76

class GG():

    def __init__(self):
        self.dependent_data = {
            "tre":5345.5,
            "fdg":"ytery"
        }

    def print(self, b):
        print("打印我自己:", b)

    def wai(self):
        wb = openpyxl.load_workbook("D:/garbage/test.xlsx")
        sheet = wb[wb.sheetnames[0]]
        expr = sheet.cell(row=1, column=1).value
        try:
            exec(expr)
        except Exception as e:
            print("err：", e)


def sssshh(a):
    print("sssshh：", a)

def task_1(i):
    while i < 1000:
        print("i：", i)
        if i == 500:
            raise AssertionError
        i += 1
    time.sleep(1)

task_list = []
def thread_pool_1():
    for i in range(1):
        task_list.append(handle_thread_pool.submit(task_1, i))
    # wait(task_list, return_when=ALL_COMPLETED)
    handle_thread_pool.shutdown()

def new_matching_variable(incoming_params: str, var: dict):
    incoming_params = Template(incoming_params).safe_substitute(var)
    try:
        params = eval(incoming_params)
    except Exception as e:
        print("error：", repr(e))
        params = incoming_params

    return params

if __name__ == '__main__':
    # resp = httpx.request("get", 'https://dev.tiktok.api.vodeshop.com/api/v1/hot-live-room', headers={"token": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvZGV2LnRpa3Rvay5hcGkudm9kZXNob3AuY29tXC9hcGlcL3YxXC9hdXRoXC9sb2dpblwvc21zIiwiaWF0IjoxNjQ5NTYyMDQyLCJleHAiOjE3MDk1NjIwNDIsIm5iZiI6MTY0OTU2MjA0MiwianRpIjoiSGhqc0Rsb1NveXlpekhWWiIsInN1YiI6MzIsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.3DKQG087OHdQ8ck3SgtaTJztzuzZjnkimdhl_N-KHMo"})
    # print(resp.text)

    # r = 0
    # try:
    #     if r < 1:
    #         # raise ResponseException(resp.text)
    #         print("r：", repr(r))
    # except Exception as e:
    #     print("e：", repr(e))
    # else:
    #     print("else")
    # finally:
    #     print("finally")
    #
    # for k, v in m1.items():
    #     if isinstance(k, tuple):
    #         print("tuple：", k[0], k[1])
    #     print(k, v)
    #
    # expr ="""
    # data = resp.json()["data"]
    # live = data[randint(0, len(data) - 1)]
    #
    # dependent_data["live_id"] = live["id"]
    # dependent_data["anchor_id"] = live["anchor"]["id"]
    #
    # print("dependent_data：", dependent_data)
    # """

    wb = openpyxl.load_workbook("D:/garbage/test.xlsx")
    sheet = wb[wb.sheetnames[0]]
    expr = sheet.cell(row=1, column=1).value
    try:
        print("expr：", expr)
        expr = matching_variable(expr)
        print("new expr：", type(expr), expr)
        exec(expr)
    except Exception as e:
        print("err：", e)



    # s = re.findall('"id":(.+?),', resp.text)
    # print("sd ：", s)

    # code = jsonpath.jsonpath(resp.json(), "$.data[0].test")
    # print("code：", code)

    # # # # var = "int"
    # # # # o = "1000"
    # # # # print(type(getattr(Util(), var)(o)))
    # # #
    # # # m = {
    # # #     "a":"1",
    # # #     "b":"",
    # # #     "c":"4",
    # # #     "d":"",
    # # #     "e":"",
    # # #     "f":{
    # # #         "g":[
    # # #             {
    # # #                 "j":"$j"
    # # #             },
    # # #             "$i"
    # # #         ],
    # # #         "h":{
    # # #             "k":"$k",
    # # #             "l":[
    # # #                 '$n'
    # # #             ]
    # # #         }
    # # #     }
    # # # }
    # # #
    # # # print("m：", m)
    # # # for k,v in m.items():
    # # #     if v == "" or v is None:
    # # #         m[k] = m1[k]
    # # # print("m：", m)
    # # #
    # # # l = ["b", "d", "e"]
    # # # print("l：", l)
    # # # for i in range(0, len(l) - 1):
    # # #     try:
    # # #         l[i] = str(m1[l[i]])
    # # #     except Exception:
    # # #         pass
    # # # print("l：", l)
    # # #
    # # # '"p":$p'

    params = '{"a":${int($a)},"b":${b},"c":"4","d":${d},"e":${e},"f":{"g":[{"j":${j}},"${i}"],"h":{"k":${k},"l":[${n},${sum_value(random(${b},reduce_value(${n}, ${p}, ${d})),${o},${b})}],"p":${sum_value($o,3)}}}}'
    # params = 'https://dev.tiktok.api.vodeshop.com/api/v1/alliance/goods?page=$j&tag=$i&sort_type=${sum_value(${o},-1)}&search_type=$d'
    # params = ""
    template = Template(params).safe_substitute(m1)
    print("template：", template, type(template))
    r = re.findall('\\${(.*?)}', template)
    print("r：", r)

    # template_new = matching_variable(template)
    # print("template_new：", template_new, type(template_new))
    # print(type(template_new["f"]["g"][1]), type(template_new["f"]["h"]["k"]), type(template_new["f"]["g"][0]["j"]))
    #
    # from selenium import webdriver as web_driver
    # chrome_options = web_driver.ChromeOptions()
    # chrome_options.binary_location = r'F:\Google\Chrome\Application\chrome.exe'
    # # 增加无界面选项
    # chrome_options.add_argument('--headless')
    # # 如果不加这个选项，有时定位会出现问题
    # chrome_options.add_argument('--disable-gpu')
    # browser = web_driver.Chrome(options=chrome_options)
    #
    # browser.get('https://test.livetools.vodeshop.com/')
    #
    # # # # # print(ast.literal_eval("https://dev.tiktok.api.vodeshop.com/api/v1/banner/list?code=dyshouyeguanggao"))
    # # #
    # # # i = 12
    # # # j = 13
    # # # exec("answer=i*j")
    # # # print("Answer is %s" % answer)
    # # #
    # # # p = "675"
    # # # exec("answer = int(p)")
    # # # print("p：", type(answer))
    # # #
    # # # x = 10
    # # # y = 20
    # # # exec("x+=y")
    # # # print(x)
    # # #
    # # # loc = locals()
    # # # exec('result = sum_value(1,3)')
    # # # print("result：", loc['result'])
    # # #
    # # # f = "mhngfj"
    # # # print('${%s}' % f)
    # # #
    # # # r = matching_variable(params)
    # # # print("r：", r)
    # # # print('r["a"]：', type(r["a"]))
    # # #
    # # # # v = ""
    # # # # print(v.split(";"))
    # # # #
    # # # # # getattr(Util(), "")(1)
    # # # # #
    # # # # # ApiDependentHandle().dependent_data_acquisition("a,b,c","fdg,tyrey,yhtdr")
    # # # #
    # # # # ast.literal_eval(None)
    # #
    # #
    # # # for x in range(5):
    # # #     print("x：", x)
    # # #
    # # # file_data={'file':(filename,open(file_path,'rb'),'image/jpeg')}
    # #
    # # # main()
    #
    # # file = open('F:/Griffin.jpeg', 'rb')
    # # file1 = open('F:/Griffin.jpeg', 'rb')
    # # file2 = {"file": open('F:/Griffin.jpeg', "rb")}
    # # print("file2：", file2)
    # # files = [
    # #     ('waitingFile', (file)),
    # #     ('waitingFile', (file1))
    # # ]
    # # print(files)
    # # print(files["file"])
    #
    # # resp = httpx.request("get", 'https://dev.tiktok.api.vodeshop.com/api/v1/qiniu-upload-token', headers={
    # #     "authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvZGV2LnRpa3Rvay5hcGkudm9kZXNob3AuY29tXC9hcGlcL3YxXC9hdXRoXC9sb2dpblwvc21zIiwiaWF0IjoxNjQ5NzYzNDc5LCJleHAiOjE3MDk3NjM0NzksIm5iZiI6MTY0OTc2MzQ3OSwianRpIjoiVjFPbDR6c3ZRZUtqbE43TSIsInN1YiI6MzIsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.KIYZKZjPk7YZzO3bJKC7ij10YN7Am-FrlMbry-vHw2c"}
    # #                      ).json()
    # # print(resp)
    # #
    # # resp1 = httpx.request("post", 'https://upload-z2.qiniup.com', headers={
    # #     "authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvZGV2LnRpa3Rvay5hcGkudm9kZXNob3AuY29tXC9hcGlcL3YxXC9hdXRoXC9sb2dpblwvc21zIiwiaWF0IjoxNjQ5NzYzNDc5LCJleHAiOjE3MDk3NjM0NzksIm5iZiI6MTY0OTc2MzQ3OSwianRpIjoiVjFPbDR6c3ZRZUtqbE43TSIsInN1YiI6MzIsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.KIYZKZjPk7YZzO3bJKC7ij10YN7Am-FrlMbry-vHw2c",
    # #     },
    # #     data={"token":resp["data"]["uptoken"]}, files=file2).json()
    # #
    # # print(resp1)
    # # # resp2 = httpx.request("put", 'https://dev.tiktok.api.vodeshop.com/api/v1/user', headers={
    # # #     "authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvZGV2LnRpa3Rvay5hcGkudm9kZXNob3AuY29tXC9hcGlcL3YxXC9hdXRoXC9sb2dpblwvc21zIiwiaWF0IjoxNjQ5NzYzNDc5LCJleHAiOjE3MDk3NjM0NzksIm5iZiI6MTY0OTc2MzQ3OSwianRpIjoiVjFPbDR6c3ZRZUtqbE43TSIsInN1YiI6MzIsInBydiI6IjIzYmQ1Yzg5NDlmNjAwYWRiMzllNzAxYzQwMDg3MmRiN2E1OTc2ZjcifQ.KIYZKZjPk7YZzO3bJKC7ij10YN7Am-FrlMbry-vHw2c"},
    # # #                       data={"avatar":resp1["key"]}).json()
    # # # print(resp2)
    # #
    # # # resp3 = httpx.request("post", 'http://192.168.56.146:8080/upload', files=files).json()
    # # #
    # # # print(resp3)
    # #
    # # t = (2, 3, (1, 4, 5))
    # # print("t：", t[:2])
    # #
    # # # dependent_data["driver"] = getattr(web_driver, "Chrome")()
    # # # dependent_data["driver"].get("https://www.bilibili.com/")
    # #
    # # v = 6
    # # b = 9.534
    # # print(v + b)
    # #
    # # e = "hnfh"
    # # print(repr(e))
    # #
    # # t = False
    # # if t is not True:
    # #     print("**********************************")
    # #
    # # m = {}
    # # if not m:
    # #     print("%%%%%%%%%%%%%%%%%%%%%%")
    #
    # # sched = AsyncIOScheduler()
    # # sched.add_job(my_job, 'interval', seconds=5)
    # # sched.start()
    # #
    # #
    # # # try:
    # # #     asyncio.get_event_loop().run_forever()
    # # # except (KeyboardInterrupt, SystemExit):
    # # #     pass
    # #
    # # r = ast.literal_eval("dgg-fsdhdg-hdhdfh")
    # # print(r, type(r))
    # # a()
    # # b()
    # # c()
    # #
    # # uvicorn.run(app='main:app', host="127.0.0.1", port=8000, reload=True, debug=True)
    # #
    # # print("往下走。。。。。。。。。。。。。。。。。。。。。。。。。。。。。")
    #
    # # p = '{"a":"hfgh","b":[],"c":(2,3.5,"^&%^%^")}'
    # # print("o：", ast.literal_eval(p))
    #
    # # print("get：", getattr(Menu, "name"))
    #
    # # dependencies=[Depends(verify_token)]
    #
    # # a = A()
    # # setattr(a, "d", getattr(a, "c"))
    # # print("a.d：", a.d)
    # #
    # # k: D = B()
    # # print("k：", k)
    #
    # # m3 = {
    # #     "z": 43,
    # #     "x": 43.5,
    # #     "c": False,
    # #     "v": "&^%$%"
    # # }
    # #
    # # # nnnn(**m)
    # #
    # # # delattr(m3, "z")
    # #
    # # del m3['z']
    # #
    # # print("M：", m3)
    # #
    # #
    # # for i in range(5):
    # #     for j in range(3):
    # #         if j >=2:
    # #             break
    # #         print(i, j)
    # #
    # # r = ifff(5)
    # # print("r", r)
    # #
    # # print("结果：", "".split(";"))
    # #
    # # # print("反射：", getattr(B(), "")("43"))
    # #
    # # m4 = {
    # #     "j":76
    # # }
    # # m3.update(m4)
    # # print(m3)
    # #
    # # gdfgfd(m3)
    # # print(m3)
    # #
    # # repr(None)
    # #
    # # assert 1 != 2
    #
    # # GG().wai()
    #
    # # a = ast.literal_eval('5')
    # # print("a：", type(a))
    # #
    # # incoming_params = Template('{"${b}":$a}').safe_substitute(m1)
    # # print("incoming_params：", incoming_params)
    # #
    # # print(3/15)
    # # print("random：", random(1, 3/15+10))
    # #
    # # # ast.literal_eval("0+1")
    # #
    # # assert int(3/15+1) == 1
    # #
    # # print("Chrome".lower())
    # #
    # # J = "gg"
    # # if J:
    # #     print("J")
    # #
    # # # time.sleep(2)
    # #
    # # desired_caps = {
    # #     "platformName": "Android",
    # #     "platformVersion": "11",
    # #     "deviceName": "86205965",
    # #     "appPackage": "com.vodeshop.tiktok",
    # #     "appActivity": "io.dcloud.PandoraEntryActivity",
    # #     "noReset": "True"
    # # }
    # d = (2, 4, 767, 9, 87)
    # for z in d[3:]:
    #     print("z：", z)
    # desired_caps = {'platformName': 'Android',  # 平台名称
    #                 'platformVersion': '11',  # 系统版本号
    #                 'deviceName': '86205965',  # 设备名称。如果是真机，在'设置->关于手机->设备名称'里查看
    #                 'appPackage': 'com.taobao.taobao',  # apk的包名
    #                 'appActivity': 'com.taobao.tao.TBMainActivity',  # activity 名称
    #                 'noReset': True
    #                 }
    # driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)  # 连接Appium
    # driver.implicitly_wait(10)

    for port in [['86205965', '11'], ['emulator-5554', '9'], ['emulator-5556', '9'], ['192.168.31.238:5555', '9']]:
        desired_caps1 = {'platformName': 'Android',  # 平台名称
                        'platformVersion': port[1],  # 系统版本号
                        'deviceName': port[0],  # 设备名称。如果是真机，在'设置->关于手机->设备名称'里查看
                        'appPackage': 'com.taobao.taobao',  # apk的包名
                        'appActivity': 'com.taobao.tao.TBMainActivity',  # activity 名称
                        'noReset': True
                        }
        # driver1 = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps1)  # 连接Appium
        driver1 = webdriver.Remote("http://192.168.31.223:4723/wd/hub", desired_caps1)  # 连接Appium
        driver1.implicitly_wait(10)

# #     # driver.close()
# #
# #     # # time.sleep(2)
# #     # udh = UiDependentHandle()
# #     # # udh.slide(driver, *(0.5, 0.8, 0.5, 0.2, 500, 3))
# #     #
# #     # # time.sleep(5)
# #     #
# #     # print("gdf：", ast.literal_eval('{ "": ("slide", (0.5, 0.5, 0.8, 0.4))}'))
# #     #
# #     # 'android.support.v7.widget.RecyclerView resource-id[@resource-id="com.taobao.taobao:id/rv_main_container"]>android.widget.FrameLayout'
# #     #
# #     # params = '''("$xpath", '//android.support.v7.widget.RecyclerView[@resource-id="com.taobao.taobao:id/rv_main_container"]/android.widget.FrameLayout[6]')'''
# #     # template = Template(params).safe_substitute(dependent_data)
# #     # print("template：", template)
# #     #
# #     # udh.get_element_all(driver, *ast.literal_eval(template)).click()
# #     #
# #     # p = '''("$xpath", '//android.widget.FrameLayout[@resource-id="com.taobao.taobao:id/weex_render_view"]/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget.FrameLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[3]/android.widget.FrameLayout[2]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.View')'''
# #     # print("p：", p)
# #     #
# #     # template = Template(p).safe_substitute(dependent_data)
# #     # print("template：", template)
# #     #
# #     # desc = udh.get_element_all(driver, *ast.literal_eval(template)).get_attribute("content-desc")
# #     # print("desc：", desc)
# #
# #
# #
# #     x = '''{
# #      ("$xpath",'//android.widget.FrameLayout[\
# # @resource-id="com.taobao.taobao:id/weex_render_view"]/android.widget.FrameLayout/android.widget.FrameLayout\
# # /android.widget.FrameLayout/android.widget.FrameLayout/android.support.v7.widget.RecyclerView/android.widget\
# # .FrameLayout/android.widget.FrameLayout[2]/android.widget.FrameLayout[3]/android.widget.FrameLayout[\
# # 2]/android.widget.FrameLayout/android.widget.FrameLayout/android.view.View'):""
# # }'''
# #
# #     template = Template(x).safe_substitute(dependent_data)
# #     print("template：", template)
# #     template = ast.literal_eval(template)
# #     print("template：", template)
# #
# #     lj = [4,6,8,3]
# #     print("lj：", lj[:2])
# #
# #     ttt = ast.literal_eval('["gfdg-4346-hfgh7-66","hjgdf-435-gfh5-55","243-5436-3445-436-46","423-6436-36-47-455"]')
# #     print("ttt：", ttt, type(ttt[0]))
# #
# #     pressure_info = {
# #         "engine": "",
# #         "available_user_sql": "sql",
# #         "login_info": {
# #             "url": "",
# #             "method": "",
# #             "header": "",
# #             "param_type": "",
# #             "params": {
# #                 "account": 0,
# #                 "password": 1
# #             },
# #             "extract_params": [
# #
# #             ]
# #         }
# #     }
# #
# #     V = (2,)
# #     sssshh(*V)
# #
# #     sls = '{\n        "type":"mysql",\n        "driven":"mysqlconnector",\n        "username": "tiktok_marketing",\n        "password": "baTJFXGipPX8JSDK",\n        "host": "120.78.221.48",\n        "port": 3306,\n        "dbname": "tiktok_marketing",\n    }'
# #     sls = Template(sls).safe_substitute(dependent_data)
# #     esls = ast.literal_eval(sls)
# #     print("sls：", sls, type(esls))
# #
# #     num = {
# #         "pass_number": 0
# #     }
# #     num["pass_number"] = num["pass_number"] + 1
# #     print('num["pass_number"]：', num["pass_number"])
# #
# #     print(cpu_count())
# #
# #     p = json.dumps({"trigger": "cron", "hour":"10", "minute":50})
# #     print("p：", p)
# #
# #     for j in "ed7ec076-dbe9-11ec-b1bf-1c697ac9cfe3":
# #         print(j)
# #
# #     # job = {
# #     #     "is_batch": True
# #     # }
# #     # if job["is_batch"]:
# #     #     print("走了。。。。。。。。")
# #
# #     session = get_sync_db()
# #     case_group_id_list = session.query(CaseGroup.id).all()
# #     print("case_group_id_list：", case_group_id_list)
#
#     # try:
#     #     os.system("pytest -s ./testCase/test_api.py --alluredir=./testReportData")
#     # except Exception as e:
#     #     print("error：", repr(e))
#
#     # os.system("allure serve ./testReportData")
#
#     thread_pool_1()
#
#     for t in task_list:
#         t.result()
#     # wait(task_list, return_when=ALL_COMPLETED)
#
#     # mail = Mail("smtp.163.com", 465, "18570683431@163.com", "SNDOGBWRYRWATMIK", "html")
#     # mail.send_emails()
#
#     # context = open('E:/TestReport202203030410.html', 'rb').read()
#     # context = bytes.decode(context)
#     # print("context：", type(context))
#
#     # obj = {"trigger": "cron", "hour": "0-3", "minute": 45}
#     # with open('test.txt', 'w') as fp:
#     #     json.dump(obj, fp)
#
#     # qqq = {
#     #     "a": 3,
#     #     "b": 1,
#     #     "c": 2,
#     #     "d": 7,
#     #     "e": 24,
#     # }
#     #
#     # ale = new_matching_variable('{"v":sum_value($a,$b,$c,ride_value($c,$d,except_value($e, $a, reduce_value($d, $a, $c, random($b,$b)))))+1,"u":"$.ytgsdgfcgdgasdasfsgrdg",("kk",0):"$.ytgsd"}', qqq)
#     #
#     # va = new_matching_variable('{(3, (1, ride_value(2, except_value(21, sum_value(1, 2)), 10))):0,"vl":sum_value(3, 1, 2)+1}', qqq)
#     # print("ale：", ale)
#     # print("va：", va)
#     #
#     # print("ride_value：", ride_value(2, 7, 10), except_value(21, 3))
#     # print("sum_value：", sum_value(3, 1, 2))
#     #
#     # get_sync_redis().delete("tv.danmaku.bili")

    # a = ""
    # if a is not None or a != "":
    #     print("牛逼啊")


































